package com.gpframework.module.common.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.common.domain.CommonPhoneMsgTemplate;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @ClassName CommonPhoneMsgTemplateReq
 * @Author gpframework
 * @Date 2022-04-07
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class CommonPhoneMsgTemplateReq extends BaseReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("品牌id")
    private Long brandId;
    @ApiModelProperty("门店id")
    private Long storeId;
    @ApiModelProperty("消息类型")
    private String msgType;
    @ApiModelProperty("业务类型")
    private String businessType;
    @ApiModelProperty("业务名称")
    private String businessName;
    @ApiModelProperty("标题")
    private String title;
    @ApiModelProperty("accessKeyId")
    private String accessKeyId;
    @ApiModelProperty("访问的域名")
    private String endpoint;
    @ApiModelProperty("accessKeySecret")
    private String accessKeySecret;
    @ApiModelProperty("签名")
    private String signName;
    @ApiModelProperty("模板code")
    private String templateCode;
    @ApiModelProperty("模版内容")
    private String templateContent;
    @ApiModelProperty("模板参数数组JSON")
    private String templateParamsJson;
    @ApiModelProperty("扣除数量")
    private String deductionsNum;
    @ApiModelProperty("启用状态")
    private String status;
    @ApiModelProperty("排序")
    private Long sort;

    /**
     * @Description 生成查询wrapper
     * @Author greatplan@qq.com
     * @Date 2020-11-04 16:04
     * @Param [lqw]
     * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
     * @Return void
     */
    public void generatorQuery(QueryWrapper<CommonPhoneMsgTemplate> lqw, boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias + "del_status", 0);
        }
        if (StringUtils.isNotBlank(this.getTitle())) {
            lqw.eq(alias + "title", this.getTitle());
        }
        if (StringUtils.isNotBlank(this.getBusinessType())) {
            lqw.eq(alias + "business_type", this.getBusinessType());
        }
        if (StringUtils.isNotBlank(this.getBusinessName())) {
            lqw.eq(alias + "business_name", this.getBusinessName());
        }
        if (StringUtils.isNotBlank(this.getAccessKeyId())) {
            lqw.eq(alias + "access_key_id", this.getAccessKeyId());
        }
        if (StringUtils.isNotBlank(this.getEndpoint())) {
            lqw.eq(alias + "endpoint", this.getEndpoint());
        }
        if (StringUtils.isNotBlank(this.getAccessKeySecret())) {
            lqw.eq(alias + "access_key_secret", this.getAccessKeySecret());
        }
        if (StringUtils.isNotBlank(this.getSignName())) {
            lqw.like(alias + "sign_name", this.getSignName());
        }
        if (StringUtils.isNotBlank(this.getTemplateCode())) {
            lqw.eq(alias + "template_code", this.getTemplateCode());
        }
        if (StringUtils.isNotBlank(this.getTemplateParamsJson())) {
            lqw.eq(alias + "template_params_json", this.getTemplateParamsJson());
        }
        if (StringUtils.isNotBlank(this.getStatus())) {
            lqw.eq(alias + "status", this.getStatus());
        }
        if (this.getSort() != null) {
            lqw.eq(alias + "sort", this.getSort());
        }
        lqw.orderByDesc(alias + "update_time");
    }
}
